<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../../resource/css/bootstrap.min.css"/>
		<link rel="stylesheet" type="text/css" href="../../../resource/css/jedate.css"/>
		<link rel="stylesheet" type="text/css" href="../../../resource/uploader/webuploader.css"/>
		<link rel="stylesheet" type="text/css" href="../../../resource/fonts/iconfont.css"/>
		<link rel="stylesheet" type="text/css" href="../../../resource/css/common.css"/>
		<link rel="stylesheet" type="text/css" href="../../../../resources/layui/css/layui.css"/>
		<style>
			.saixuan:after{width: 0;}
			.layui-form-pane .layui-input-block{margin-left: 0;}

			@media screen and (max-width: 1280px) {
				.layui-form-pane .layui-form-label{width: 108px;}

			}

			.layui-form-item .layui-input-inline{width: 165px;}
			.masksx .forms{padding-left: 0;text-align: center;}
			.masksx{width: 650px;}
			.mask input{width: 100%!important;}
			.mask .layui-select-title{width: 480px;}
			.layui-inline{margin-bottom: 10px;}
			.layui-upload{ text-align: left;}
			#demo2 img{width: 90px; height: 90px;}
			.imgs{position: relative;width: 90px; height: 90px; float: left; margin-right: 10px; margin-bottom: 10px;}
			._ingshan{position: absolute;right: -5px;top: -5px; background-color:#ff0000;border: 1px solid #FF0000;
				border-radius: 50%;width: 22px;height: 22px;text-align: center;}
			@media only screen and (min-width: 321px) and (max-width: 1024px) {
				.layui-form-pane .layui-input-inline {width: 100%;}
				._inkong{ width:auto!important; }
				.layui-form-item .layui-input-inline{width: 100%;}
				.masksx{height: 50%;}
			}
			
			@media screen and (max-width: 750px){
				.MOVE_queryon .layui-form-item {
					width: 80%;
				}
				.layui-form-item{padding: 0;}
				.MOVE_footer{text-align: right;}
				.MOVE_footer a{color: #FFF;font-size: 20px;line-height: 30px;
					padding: 10px;background-color: #F5A721;height: 100%;position: absolute;right: 0;}
				.tijiao{z-index: 9999;}
			}
			._ingshan .layui-icon{ color: #fff; margin-top: -2px;}
			.danhao{display: none; padding-left: 32px;}
			.danhao .layui-form-label,.danhao ._inkong{float: left;}
			.danhao ._inkong{margin-bottom: 10px; }
			.masksx ._inkong{}
			.layui-table-cell{text-align: left;}
			.layui-form-select{width: 80%!important;}
			.layui-btn{ display: block; padding: 0; text-align:center;width:90px; height: 90px; border-radius: 5px; background-color: #f5f5f5;}
			.layui-btn .layui-icon{ text-align: center; color: #999; font-size: 66px; margin: 0 auto;}
			.layui-quote-nm{ padding: 0; border:none;}
		</style>
	</head>
	<body>
		<div class="container-fluid">
			<div class="row mheader">
				<div class="col-xs-2 text-left"> <a href="javascript:;" onclick="javascript:history.back(-1);"><span class="iconfont icon-fanhui"></span></a> </div>
				<div class="col-xs-8"><h2>编辑签证</h2></div>
				<div class="col-xs-2 text-right"><a href="###" onclick="tijiao()">确定</span></a></div>
			</div>
			<div class="row">
				<div class="com-form ">
					<form class="form-horizontal">
						
					</form>
				</div>
			</div>
			
		</div>
	</body>
</html>
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="../../../resource/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../resource/uploader/webuploader.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../resource/js/style.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../resources/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
// 百度上传图片插件

	function tijiao() {
		var cs_id=sessionStorage.cs_id;
		var s_img=_picurls;
		var s_content=$('#neirong').val();
		var s_person=$('.s_person').val();
		console.log(s_content)

		ajaxs('api/buil/builSignHisBaoEdit.do','post',{'cs_id':cs_id,'s_img':s_img,'s_content':s_content,'s_person':s_person,'p':getP()},function (data) {
			console.log(data)

			if(data.code==0){
                window.tool.alert(data.msg);
			    location.href='./visa-list.html';
			}

        })

    }


	var _picurls=new Array();



 	ajaxs('api/buil/builSignHisDetail.do','post',{'p':getP(),'cs_id':sessionStorage.cs_id},function (data) {
		console.log(data);
		var das=data.data[0];
		$('.form-horizontal').append('<div class="form-group">' +
            '<label class="col-xs-3 control-label" for="">合同编号:</label>' +
            '<div class="col-xs-9">' +
            '<input type="text" readonly class="form-control" id="" placeholder="" value="'+das.cc_Code+'">' +
            '</div>' +
            '</div>' +
            '<div class="form-group">' +
            '<label class="col-xs-3 control-label" for="">工程名称:</label>' +
            '<div class="col-xs-9">' +
            '<input type="text" readonly class="form-control" id="" placeholder="" value="'+das.proName+'">' +
            '</div>' +
            '</div>' +
            '<div class="form-group">' +
            '    <label class="col-xs-3 control-label" for="">签证人:</label>' +
            '    <div class="col-xs-9">' +
            '    <input type="text" readonly class="form-control s_person" id="" placeholder="" value="'+das.s_Person+'">' +
            '    </div>' +
            '  </div>' +
            '  <div class="form-group">' +
            '    <label class="col-xs-3 control-label" for="">签证内容:</label>' +
            '    <div class="col-xs-9">' +
            '    <textarea class="form-control" rows="3" id="neirong">'+das.s_Content+'</textarea>' +
            '    </div>' +
            '  </div>' +
            '<div class="form-group">' +
            '<label class="col-xs-3 control-label">现场图:</label>' +
            '<div class="layui-input-inline col-xs-9">' +
            '<div class="layui-upload">' +
            '<button type="button" class="layui-btn" id="test2"><i class="layui-icon">&#xe654;</i> </button>' +
            '<blockquote class="layui-elem-quote layui-quote-nm">' +
            '<div class="layui-upload-list clearfix" id="demo2"></div>' +
            '</blockquote>' +
            '</div>' +
            '</div>' +
            '</div>')





        layui.use(['form', 'layedit', 'laydate','table','element','upload','flow'], function() {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                , table = layui.table
                , element = layui.element
                , flow = layui.flow
                , upload = layui.upload;

            var img_arr=new Array();
            if(das.s_img){
                img_arr=das.s_Img;
                img_arr=img_arr.split(',');
                for(var i=0;i<img_arr.length;i++){
                    $('#demo2').append('<div class="imgs"><img src="'+ img_arr[i] +'" class="layui-upload-img"> <span class="_ingshan"><i class="layui-icon">&#x1006;</i> </span></div>')
                }
			}


            $(document).on('click','._ingshan',function () {
                console.log($(this).prev().attr('src'))
                var shanSRC=$(this).prev().attr('src');
                $(this).parent().remove();
                $.each(_picurls,function(index,item){       //删除功能
                    // index是索引值（即下标）   item是每次遍历得到的值；
                    if(item==shanSRC){
                        _picurls.splice(index,1);
                    }
                });
                console.log(_picurls)
            })

            //图片上传
            upload.render({
                elem: '#test2'
                ,url: urls+'/api/public/uploadImg.do'
                ,multiple: true
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8

                }
                ,done: function(res){
                    //上传完毕
                    console.log(res)
                    _picurls.push(res.data[0]);         //返回的数据  放进数组中以便传递

                    $('#demo2').append('<div class="imgs"><img src="'+ res.data[0] +'" class="layui-upload-img"> <span class="_ingshan"><i class="layui-icon">&#x1006;</i> </span></div>')

                }
                ,error: function(index, upload){
                    //当上传失败时，你可以生成一个“重新上传”的按钮，点击该按钮时，执行 upload() 方法即可实现重新上传
                    console.log(index,upload)
                }
            });


        });


    })
</script>






